﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperKit
{
    /*
     * 这个项目用来在项目前面增加一个星星。再简单不过的项目。
     */
    class AddFavorMark : CommandExecutor {

        private string mark;
        public bool IsRemove { get; }

        public AddFavorMark(ArgReader arg, IExecutorOwner form, string fpath) : base(arg, form, fpath) {
            mark = arg.GetParameter("-mark", Kit.FAVOR_START);
            IsRemove = arg.IsContain("-remove");
        }


        public override void Execute() {
            base.Execute();

            DirectoryInfo info = new DirectoryInfo(FilePath);

            var name = info.Name;
            if (IsRemove) {
                name = name.Replace(mark, "");
            } else {
                name = Kit.AddFavorStar(info.Name, mark);
            }

            var newPath = Path.Combine(info.Parent.FullName, name);

            if (!Directory.Exists(newPath)) {
                Directory.Move(info.FullName, newPath);
            }


            End();
        }

    }
}
